package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealMapper {
    /**
     * 查询分类关联的套餐数量
     * @param id
     * @return
     */
    @Select("select count(*) from sky_take_out.setmeal where category_id=#{id}")
    Integer countByCategoryId(Long id);


    /**
     * 套餐分页查询
     * @param setmealPageQueryDTO
     * @return
     */
    List<SetmealVO> page(SetmealPageQueryDTO setmealPageQueryDTO);

    /**
     * 新增套餐
     * @param setmeal
     */
    @AutoFill(value = OperationType.INSERT)
    void save(Setmeal setmeal);

    /**
     * 查询套餐
     * @param id
     * @return
     */
    @Select("select *from sky_take_out.setmeal where id=#{id}")
    Setmeal getById(Long id);

    /**
     * 修改套餐
     * @param setmeal
     */
    @AutoFill(value = OperationType.UPDATE)
    void update(Setmeal setmeal);

    /**
     * 删除套餐
     * @param ids
     */
    void del(List<Long> ids);

    /**
     * 查询套餐总览
     * @param status
     * @return
     */
    @Select("select count(*)from sky_take_out.setmeal where status=#{status}")
    Integer overviewSetmeals(Integer status);
}
